import datetime
import multiprocessing
import random
from multiprocessing.spawn import freeze_support

# from multiprocessing import freeze_support

from req import LiveRoom
from service.schedule import ScheduleService

if __name__ == '__main__':
    # init_table()
    # bag=LiveRoom("http://xasdfasdf","douyin://xxxx","111","2024-05-17 13:06:43","03:23",1)
    s=datetime.datetime.now()

    print("lazy")
    total=0
    ll = []
    # freeze_support()
    sc=ScheduleService()
    for c in  range(0,10):
        ll.clear()
        for i in range(0,9999):
            room=LiveRoom()
            room.room_id= f"1000{i*c}"
            room.bag_rem_time= "03:23"
            room.scheme_url= "ssndk1123://xasdfasdf"
            room.room_link= "http://tiktok.com/xxxx"
            room.datatime= "2024-05-17 13:06:43"
            room.gold_num=random.randint(1,30)
            # ll.append(room)
            sc.save_live_room(room)
        # insert_or_update_live_room_batch(ll)
        total+=len(ll)
    print(f"{total} {(datetime.datetime.now()-s)}" )

    freeze_support()
